<template>
  <div class="commission_detail-container">
    <breadcrumb style="position: absolute;width:100%;"></breadcrumb>
    <img src="../../img/return_icon.png" alt @click="$router.go(-1)">

    <div class="content">
      <div class="query">
        <div class="right">
            <el-button type='primary' @click="Fan">返回</el-button>
        </div>
      </div>
      <div class="table" v-if="list">
        <el-table :data="detailList" style="width: 100%" height="528">
          <el-table-column prop="userNo" label="团员ID"></el-table-column>
          <el-table-column prop="teamUserName" label="团员名称"></el-table-column>
          <el-table-column label="团队">
            <template slot-scope="scope">
              <div class="cell" v-if="scope.row.teamLevel == 1">{{'直推'}}</div>
              <div class="cell" v-else>{{'间推'}}</div>
            </template>
          </el-table-column>
          <el-table-column prop="note" label="活动类型"></el-table-column>
          <el-table-column prop="commission" label="佣金结算金额（元）"></el-table-column>
          <el-table-column prop="balanceMiniPay" label="实际支付金额（元）"></el-table-column>
           <el-table-column label="实际支付方式">
            <template slot-scope="scope">
              <div class="cell" v-if="scope.row.orderItem == 1">{{'钻石支付'}}</div>
              <div class="cell" v-else>{{'富友支付'}}</div>
            </template>
          </el-table-column>
          <el-table-column width="200px" prop="transactionNo" label="订单号"></el-table-column>
          <el-table-column prop="sysTime" label="下单时间"></el-table-column>
          <el-table-column label="该笔佣金状态" prop="commissionStatus">
            <template slot-scope="scope">
              <el-select @change="handlede(scope.row.id,scope.row.commissionStatus)" v-model="scope.row.commissionStatus" placeholder="请选择">
                <el-option
                  v-for="item in zhuangts"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value">
                </el-option>
              </el-select>
            </template>
          </el-table-column>
        </el-table>
        <pagination
          :currentPage="currentPage"
          :page="page"
          :total="total"
          :pageSize="pageSize"
          @change-current="currentChange"
          @change-size="sizeChange"
        ></pagination>
      </div>
      <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%" >
     <span><span style="color:red;font-size:2rem;" class="el-icon-warning"></span>此操作将切换该用户该笔佣金状态（正常/冻结），是否继续？</span>
     <span slot="footer" class="dialog-footer">
     <el-button @click="dialogVisible=false" style="width:70px;">取 消</el-button>
     <el-button type="primary" @click="getProhibit" style="width:70px;">确 定</el-button>
      </span>
    </el-dialog>
    </div>
  </div>
</template>

<script>
import breadcrumb from "../../components/breadcrumb";
import pagination from "../../components/page";
import {cumulative,commissionfs} from '../../api/getData'
export default {
  components: { breadcrumb, pagination },
  data() {
    return {
      dialogVisible:false,
      page: 1,
      userId: this.$route.query.id,
      currentPage: 1,
      pageSize: 10,
      total: 0,
      username: "",
      startTime:'',
      endTime:'',
      levelOneNum:'',
      levelTwoNum:'',
      commissionSum:'',
      detailList: [],
      list:true,//提现明细的显示和影藏
      lists:false,//佣金获得明细的显示和隐藏
      zhuangts:[
          {value:0,label:"冻结"},
          {value:1,label:"正常"}
        ],
      shuju:"",
      shuju1:"",
    };
  },
  created() {
    this.get_cumulative()
  },
  methods: {
    sizeChange(val) {
      this.pageSize = val;
      this.currentPage = 1;
      this.get_cumulative()
    },
    handlede(id,auditCommission){
      this.dialogVisible=true;
      this.shuju=id;
      this.shuju1=auditCommission;
      this.get_cumulative()
    },
    currentChange(val) {
      this.currentPage = val;
      this.get_cumulative()

    },
    get_cumulative(currentPage){
      if(currentPage){
        this.currentPage = currentPage
      }
      // let data = 'endTime=' + this.endTime + "&startTime=" + this.startTime + '&userId=' + this.userId + '&size=' + this.pageSize + '&current=' + this.currentle't
      let data ="userId="+this.userId+"&current="+this.currentPage;
      cumulative(data).then(res => {
        //console.log(res,'单个')
        if(res.data.status == 0 && res.data.data.records.length != 0){
          this.total = res.data.data.total 
          this.page = Math.ceil(this.total / this.pageSize)
          this.detailList = res.data.data.records
          this.detailList.forEach(item=>{
            item.commissionStatus=item.commissionStatus*1
          })
          this.levelOneNum = res.data.data.records[0].levelOneNum
          this.levelTwoNum=res.data.data.records[0].levelTwoNum
          this.commissionSum =res.data.data.records[0].commissionSum
        }
      })
    },
    //控制提现明细的显示和
    getList(){
        this.list=!this.list
        this.lists=!this.lists
    },
    //控制佣金获得明细
    getLists(){
        this.lists=!this.lists
        this.list=!this.list
    },
    //点击返回上一级页面
    Fan(){
        this.$router.go(-1)
    },
    getProhibit(){
      let data='Id='+this.shuju+"&commissionStatus="+this.shuju1+"&userId="+this.userId
        commissionfs(data).then(res=>{
          this.dialogVisible=false
          //console.log(res.data.data)
          if(res.data.data==true){
            this.get_cumulative()
            this.$message({
                  type:'success',
                  message:'修改成功'
            });
          }else{
            this.$message.error('修改失败');
            this.get_cumulative()
          }
          
        })
    }
  }
};
</script>


<style lang="less" >
.commission_detail-container {
  @import "../../style/table.less";
  @import "../../style/content.less";
  display: flex;
  flex-flow: column;
  position: relative;
  height: 100%;
  .el-table .cell {
    white-space: pre-line !important;
  }
  > img {
    position: absolute;
    width: 30px;
    height: 30px;
    top: 5px;
    right: 40px;
    z-index: 99;
    cursor: pointer;
  }
  .content {
    .query {
      .btn {
        .el-button {
          width: 70px;
        }
      }
      .start_time {
        display: flex;
        align-items: center;
      }
      .end_time {
        display: flex;
        align-items: center;
      }
    }
  }
}
</style>